import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../controllers/wrap_controller.dart';

/// wrap的用法，类似flow布局，水平和垂直都可以
class WrapView extends GetView<WrapController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('WrapView'),
        centerTitle: true,
      ),
      body: Container(
        child: Obx(
          () => Wrap(
            direction: Axis.vertical,
            spacing: 10,
            runSpacing: 20,
            children: controller.items
                .map(
                  (element) => Container(
                    height: 100,
                    width: 120,
                    color: Colors.orange,
                  ),
                )
                .toList(),
          ),
        ),
      ),
    );
  }
}
